<?php

/*
 * 容器与依赖注入
 */
namespace app\controller;


use app\model\One;

class Inject
{
    public $one;
    //依赖注入
    public function __construct(One $one)
    {
        $this->one  = $one ;
    }
    public function index(){
      return $this->one->username;
    }

    public function bind(){
//        bind('one','app\model\One');
//        return app('one')->username;

//        bind('one','app\model\One');
//        return app('one',[['ghj520']],true)->username;

//        return app('app\model\One')->username;


        //bind() 也可以批量绑定
        bind([
           'one' => 'app\model\One'
        ]);
        return app('one')->username;
    }
}